package com.taoym.voucher.xcx.controller;

import com.taoym.voucher.common.response.Response;
import com.taoym.voucher.xcx.entity.dto.XcxECGetGoodsConvertDTO;
import com.taoym.voucher.xcx.entity.dto.XcxECGetGoodsDTO;
import com.taoym.voucher.xcx.entity.dto.XcxECGetRecommendGoodsDTO;
import com.taoym.voucher.xcx.entity.vo.XcxECGetGoodsConvertVO;
import com.taoym.voucher.xcx.entity.vo.XcxECGetGoodsVO;
import com.taoym.voucher.xcx.entity.vo.XcxECGetPlatformVO;
import com.taoym.voucher.xcx.service.XcxECommerceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @coder taoym
 * @datetime 2021/8/23 15:33
 * @desc 电商控制器
 */
@RestController
@RequestMapping("/ec")
@Api(tags = "电商控制器")
public class XcxECommerceController {

    @Autowired
    private XcxECommerceService xcxECommerceService;

    @GetMapping("/list/goods")
    @ApiOperation("查询商品")
    public Response<List<XcxECGetGoodsVO>> listGoods(@Valid XcxECGetGoodsDTO data) {
        return Response.success(xcxECommerceService.listECGoods(data));
    }

    @GetMapping("/list/platform")
    @ApiOperation("查询电商平台信息")
    public Response<List<XcxECGetPlatformVO>> listECPlatform() {
        return Response.success(xcxECommerceService.listECPlatform());
    }

    @GetMapping("/convert")
    @ApiOperation("商品转链")
    public Response<XcxECGetGoodsConvertVO> goodsConvert(@Valid XcxECGetGoodsConvertDTO data) {
        return Response.success(xcxECommerceService.goodsConvert(data));
    }

    @GetMapping("/list/recommend")
    @ApiOperation("推荐商品")
    public Response<List<XcxECGetGoodsVO>> recommendGoods(@Valid XcxECGetRecommendGoodsDTO data) {
        return Response.success(xcxECommerceService.recommendGoods(data));
    }
}
